<template>
  <div class="container">
    <div>
      <van-nav-bar title="商圈云年底钜惠"
                   left-text=""
                   @click-left="onClickLeft"
                   class="title"
      />
    </div>

    <div>

      <van-form @submit="onSubmit" class="content">
        <div style="font-size: 16px;font-weight: bold;padding-top: 10px;text-indent: 32px;padding-left: 10px;color: red;">
          1.转终生端口钜惠活动
        </div>
        <div class="text">
          （1）2023年12月26日之前，凡是“未到期”的按年缴费的端口，都可以直接抵扣上一次的缴费金额，转为终生端口，比如上次缴费1600元，只需再交2600元-1600元=1000元即可直接转为终生端口，并且赠送一年服务费，后续每个端口每年只需100元服务费，即可终生使用。
        </div>
        <div class="text">
          （2）已经是终生端口的，每个端口只需一次性交500元服务费，即可享受终生无服务费政策。
        </div>
        <div style="font-size: 16px;font-weight: bold;padding-top: 10px;text-indent: 32px;padding-left: 10px;color: red;">
          2.老客户升级战略合伙人
        </div>
        <div class="text">
          为进一步回馈商圈云资深老客户，2023年12月26日前，特邀100位使用商圈云超过一年的老客户做为战略合伙人，合伙人推荐客户直接给予现金奖励。
        </div>
        <div class="text">
          以上政策详情，有意向的老客户请联系各自的对口业务经理。也可以直接拨打400-800-1556，客服会帮各位转达给您的对口业务经理。
        </div>

        <div  class="text">
          2023年确实不易，感谢各位一直以来的信任与支持！
        </div>

        <div  class="text">
          2024年，商圈云将继续与各位一起，乘风破浪，披荆斩棘，谱写新的历史篇章！
        </div>
      </van-form>
    </div>
  </div>
</template>

<script>
import {saveReport,saveReportReadNum ,uploadShareImg,saveDkinfo} from 'api/api'
import {Toast} from 'vant'
export default {
  name: 'myquanzi',
  data() {
    return {
      xq1:'',
      xq2:'',
      xq3:'',
      xq4:'',
      xq5:'',
      xq6:'',
      xq7:'',
      xq8:'',
      xq9:'',
      xq10:'',
      agencyid:'',
      gsname:'',
      frname:'',
      frsfzh:'',
      dkje:'',
      ppname:'',
      phone:'',
      fileList:[],
      images:[],

    }
  },
  created() {

    const agencyId = this.$route.query.agencyId
    this.agencyid = agencyId
    this.saveReportReadNum()

    let  xtname = this.viewczxt()
    let that = this
    if(xtname == "Android"){
      document.addEventListener('message', function(msg) {
        console.log(msg);
        that.images.push(msg.data + '')
        //如果需要获取msg里面的值。需要msg.data。
        //当时这个坑卡了好久，因为不方便查看msg里面的东西，直接用msg.是获取不到东西的。
        //还有，记住使用  JSON.parse(msg.data)  才能获取到你的东西!!!
      });

    }else{
      window.onload = function() {
        window.addEventListener("message", function(event) {
          console.log('app发送信息：')
          console.log(event.data)
          that.images.push(msg.data + '')
        });
      }
    }

  },
  methods: {
    //识别操作系统
    viewczxt(){
      var u = navigator.userAgent, app = navigator.appVersion;
      var isXiaomi = u.indexOf('XiaoMi') > -1; // 小米手机
      var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; // 其它安卓
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios
      if (isAndroid) {
        return "Android"
      }else if (isIOS) {
        if(isXiaomi) {
          return  "Android"
        }else {
          return  "Ios"
        }
      }
    },

    onClickLeft() {
      this.$router.go(-1) // 返回上一层
    },

    onSubmit(){
      let param = {}
      param.agencyid = this.agencyid
      param.phone = this.phone
      param.frname = this.frname
      param.frsfzh = this.frsfzh
      param.gsname = this.gsname
      param.dkje = this.dkje
      param.ppname = this.ppname
      param.yyzzurl = this.images.toString()



      if(!param.frname){
        Toast.fail('请输入法人姓名')
        return
      }

      if(!param.frsfzh){
        Toast.fail('请输入法人身份证号')
        return
      }

      if(!param.gsname){
        Toast.fail('请输入公司名称')
        return
      }

      if(!param.dkje){
        Toast.fail('请输入贷款金额')
        return
      }

      if(!param.ppname){
        Toast.fail('请输入代理品牌')
        return
      }

      if(!param.phone){
        Toast.fail('请输入您的手机号，以便跟您联系')
        return
      }


      saveDkinfo(param).then(response => {
        if (response.code === 200) {
          //Toast.success('保存成功')
          this.$router.push({ path: '/success', query: {}})
        }else{
          Toast.fail(response.msg)
        }
      })

    },

    saveReportReadNum(){
      let param = {}
      param.dictType = 'report_readed'
      saveReportReadNum(param).then(response => {
        if (response.code === 200) {

        }else{
          // Toast.fail(response.msg)
        }
      })
    },


    /**
     * 删除附件
     * @param {*} e
     */
    delImgs:function(item){
      console.log(item)
      console.log(this.images)
      let that = this
      let images = that.images
      let length = images.length
      for(var i=0;i<length;i++){
        if(images[i] == item.item){
          that.images.splice(i,1)
        }
      }
    },

    selectTp(){
      window.postMessage('camera');
      document.getElementById("uploadfileid").click();
    },

    fileSelected() {
      var file = document.getElementById('uploadfileid').files[0];
      if (file) {
        var fileSize = 0;
        if (file.size > 1024 * 1024)
          fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
        else
          fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';

        console.log(file.name)
        console.log(fileSize)
        console.log(file.type)

        let formData = new FormData();
        formData.append("file", file);
        formData.append("type","quanzi")
        let fileList = []
        uploadShareImg(formData).then(response => {
          console.log(response)
          if(response.code == 200 ){
            fileList.push(response.data.url)
            this.images.push(response.data.url+'')
            this.fileList.concat(fileList)
            console.log(this.fileList)
            console.log(this.images)
          }
        });

      }
    }


  }

}
</script>

<style scoped>

.container{
  background-color: white;
  height: auto;
}

.columnr{
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
}

.rownr{
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
  font-size: 16px;
}

.text{
  text-indent: 32px;
  padding-left: 10px;
  padding-right: 10px;
  font-size: 16px;
  padding-top: 10px;
  line-height: 200%;
}

.text1{
  padding-left: 10px;
  padding-right: 10px;
  font-size: 14px;
  padding-top: 15px;
  line-height: 200%;
}

.box {
  position: relative;
  display: inline-block;
  padding-left: 12px;
}
.box .clear {
  position: absolute;
  top: 0;
  right: 0;
}

.content {
  padding-top: 10px;
  width: 100%;
  height:auto;

}

.title{
  color: black;
  font-weight: bold;
  font-size: 22px;
  text-align: center;
  width: 100%;
  padding-top: 10px;


}
</style>
